<template>
	<view class="box">
		<view class="box-cen">
			<view class="box-text">
				<timeLine :list="list"></timeLine>
			</view>
		</view>
	</view>
</template>

<script>
	const meetingMap = {
		year: {
			type: 'text',
			name: '年份',
			filter: (val) => val
		},
		number: {
			type: 'text',
			name: '项目编码',
			filter: (val) => val
		},
		project_name: {
			type: 'text',
			name: '项目名称',
			filter: (val) => val
		},
		type: {
			type: 'text',
			name: '类别',
			filter: (val) => val
		},
		depart: {
			type: 'text',
			name: '承担部门',
			filter: (val) => val
		},
		person_liable: {
			type: 'text',
			name: '项目负责人',
			filter: (val) => val
		},
		charge_person: {
			type: 'text',
			name: '实际负责人',
			filter: (val) => val
		},
		item_time: {
			type: 'text',
			name: '立项时间',
			filter: (val) => val
		},
		total_money: {
			type: 'text',
			name: '项目总费用',
			filter: (val) => val
		},
		coop_unit: {
			type: 'text',
			name: '合作单位',
			filter: (val) => val
		},
		plan_start_time: {
			type: 'text',
			name: '项目计划时间',
			filter: (val) => val 
		},
		current_process: {
			type: 'text',
			name: '当前进展',
			filter: (val) => val
		},
		paper_require: {
			type: 'text',
			name: '论文（篇）',
			filter: (val) => val
		},
		profession_require: {
			type: 'text',
			name: '专利（项）',
			filter: (val) => val
		},
		soft_require: {
			type: 'text',
			name: '软著（篇）',
			filter: (val) => val
		},
		
		
		total_money: {
			type: 'text',
			name: '总费用（万元）',
			filter: (val) => val
		},
		contract_money: {
			type: 'text',
			name: '合同金额（万元）',
			filter: (val) => val
		},
		year_2021_total: {
			type: 'text',
			name: '2021年当年费用',
			filter: (val) => val
		},
		year_2022_total: {
			type: 'text',
			name: '2022年当年费用',
			filter: (val) => val
		},
		contract_date: {
			type: 'text',
			name: '合同签订',
			filter: (val) => val
		},
		begin_question: {
			type: 'text',
			name: '开题',
			filter: (val) => val
		},
		interim_acceptance: {
			type: 'text',
			name: '中期验收',
			filter: (val) => val
		},
		contract_acceptance: {
			type: 'text',
			name: '合同验收（自验收）',
			filter: (val) => val
		},
		final_acceptance: {
			type: 'text',
			name: '最终验收',
			filter: (val) => val
		},
		receive_money: {
			type: 'text',
			name: '已入账（万元）',
			filter: (val) => val
		},
		pay_money: {
			type: 'text',
			name: '已支付（万元）',
			filter: (val) => val
		},
		unpay_first_pay: {
			type: 'text',
			name: '首付款（万元）',
			filter: (val) => val
		},
		unpay_year_2021_pay: {
			type: 'text',
			name: '21年进度款支付（万元）',
			filter: (val) => val
		},
		unpay_interim_acceptance: {
			type: 'text',
			name: '中期验收（万元）',
			filter: (val) => val
		},
		unpay_final_acceptance: {
			type: 'text',
			name: '验收款（万元）',
			filter: (val) => val
		},
		remark: {
			type: 'text',
			name: '备注',
			filter: (val) => val
		}
	};
	import timeLine from '@/components/time_line/index.vue';
	import {
		getTecProjectDetail,
		getTecProjectImplementDetail
	} from  '@/api/technology.js';
	export default {
		components: {
			timeLine
		},
		data() {
			return {
				curidx: '',
				curname: '',
				id: '',
				list: []
			}
		},
		methods: {
			async fetchData() {
					uni.showLoading({
						title: '加载中...'
					});
					if(this.curidx==0){
						const {
							data
						} = await getTecProjectDetail({
							id:this.id
						});
						if (data.code === 1) {
							let arr = []
							let res = data.data
							for (let key in meetingMap) {
								let item = {}
								if (meetingMap[key]) {
									var type = meetingMap[key].type
									item = {
										title: meetingMap[key].name,
										content: {
											type: type,
											value: meetingMap[key].filter(res[key])
										}
									}
									if (res[key] != null && res[key] != '') {
										arr.push(item)
									}
								}
							}
								this.list = arr
						}
					}else if(this.curidx==1){
						const {
							data
						} = await getTecProjectImplementDetail({
							id:this.id
						});
						if (data.code === 1) {
							let arr = []
							let res = data.data
							for (let key in meetingMap) {
								let item = {}
								if (meetingMap[key]) {
									var type = meetingMap[key].type
									item = {
										title: meetingMap[key].name,
										content: {
											type: type,
											value: meetingMap[key].filter(res[key])
										}
									}
									if (res[key] != null && res[key] != '') {
										arr.push(item)
									}
								}
							}
								this.list = arr
						}
					}
					uni.hideLoading();
				
				}
		},
		onLoad(data) {
			this.id = data.id
			this.curidx = data.curIdx
			this.curname = data.curName
			console.log(data)
		},
		onReady() {
			this.fetchData();
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		width: 100%;
		height: 100rpx;
		background-color: #2658FA;

		.box-cen {
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			background-color: #fff;

			.box-text {
				padding: 50rpx 30rpx;
			}
		}
	}
</style>
